// @ts-ignore
import request, { TR } from "@/utils/request";

export default {
  // 组件
  components: {
    // 组件列表查询
    page: (params) =>
      TR(request.post("/ttadmin/component/findByCondition", params)),
    // 组件详情查询
    detail: (params) =>
      TR(request.post("/ttadmin/component/findComponentById", params)),
    // 组件新增
    add: (params) =>
      TR(request.post("/ttadmin/component/saveComponent", params)),
    // 组件修改
    update: (params) =>
      TR(request.post("/ttadmin/component/updateComponent", params)),
    // 组件删除
    delete: (params) =>
      TR(request.post("/ttadmin/component/deleteComponent", params)),
    // 校验组件下是否有组件版本
    check: (params) => TR(request.post("/component/check", params)),
    // 组件修改记录列表查询
    modifyList: (params) => TR(request.post("/component/modifyList", params)),
    // 上架列表
    shelvesList: (params) =>
      TR(request.post("/ttadmin/component/getAvailablesList", params)),
    // 组件唯一标识是否存在
    checkUniqueIdExists: (params) =>
      TR(request.post("/ttadmin/component/checkUniqueIdExists", params)),
    // 判断组件下是否存在版本
    checkVersionExists: (params) =>
      TR(request.post("/ttadmin/component/hasComponentVersion", params)),
    // 验证组件目录下是否已存在组件
    checkComponentExists: (params) =>
      TR(request.post("/ttadmin/component/checkTitleExists", params)),
    // 校验组件唯一标识是否唯一
    checkUniqueIdAvailable: (params) =>
      TR(request.post("/ttadmin/component/checkUniqueIdAvailable", params)),
  },
  // 组件版本
  versions: {
    // 组件版本列表
    page: (params) =>
      TR(request.post("/ttadmin/componentVersion/findByCondition", params)),
    // 组件版本上架列表
    shelvesList: (params) =>
      TR(request.post("/ttadmin/component/getAvailableVersionsList", params)),

    // 组件版本详情
    detail: (params) =>
      TR(
        request.post(
          "/ttadmin/componentVersion/componentVersionsDetails",
          params
        )
      ),
    // 组件版本新增
    add: (params) =>
      TR(
        request.post("/ttadmin/componentVersion/saveComponentVersion", params)
      ),
    // 组件版本修改
    update: (params) =>
      TR(
        request.post("/ttadmin/componentVersion/updateComponentVersion", params)
      ),
    // 组件版本删除
    delete: (params) =>
      TR(
        request.post("/ttadmin/componentVersion/deleteComponentVersion", params)
      ),
    // 校验组件版本号是否唯一
    check: (params) =>
      TR(request.post("/ttadmin/componentVersion/versionNoIsUnique", params)),
    // 组件版本提交准生产
    submit: (params) =>
      TR(request.post("/ttadmin/componentVersion/submitPreProduction", params)),
    // 组件版本提交生产
    submitPro: (params) =>
      TR(request.post("/ttadmin/componentVersion/submitProduction", params)),
    // 组件版本修改记录列表查询
    modifyList: (params) =>
      TR(request.post("/component/versions/modifyList", params)),
    // 组件版本上下架记录列表查询
    shelfList: (params) =>
      TR(request.post("/component/versions/shelfList", params)),
    // 组件版本上线审批记录列表查询
    approveList: (params) =>
      TR(request.post("/component/versions/approveList", params)),
    // 组件版本下载审批记录列表查询
    downloadApproveList: (params) =>
      TR(request.post("/component/versions/downloadApproveList", params)),
    // 组件版本代码包上传
    uploadCode: "/ttadmin/componentVersion/uploadCodePackage",
    // 组件版本JS包上传
    uploadJS: "/ttadmin/componentVersion/uploadJsPackage",
    // 组件版本代码包下载
    download: (params) =>
      TR(
        request.post("/ttadmin/component/componentVersion/download", params, {
          responseType: "blob",
        })
      ),
    // 组件版本JS包下载
    downloadJS: (params) =>
      TR(
        request.post("/ttadmin/component/componentVersion/downloadJS", params)
      ),
    // 更改上下架状态
    updateStatus: (params) =>
      TR(
        request.post(
          "/ttadmin/component/componentVersion/changeAvailable",
          params
        )
      ),
    // 申请下载
    applyDownload: (params) =>
      TR(
        request.post(
          "/ttadmin/component/componentVersion/downloadApply",
          params
        )
      ),
  },
  // 组件目录树
  category: {
    // 目录树
    tree: (params) =>
      TR(request.post("/ttadmin/componmentDirectory/directoryTree", params)),
    // 新增目录修改
    update: (params) =>
      TR(
        request.post(
          "/ttadmin/componmentDirectory/saveOrUpdateComponmentDir",
          params
        )
      ),
    // 目录删除
    delete: (params) =>
      TR(
        request.post(
          "/ttadmin/componmentDirectory/deleteComponentDirectory",
          params
        )
      ),
  },
  // 组件标签
  tag: {
    // 标签列表
    page: (params) => TR(request.post("/ttadmin/componentTag/tree", params)),
    // 标签新增
    add: (params) => TR(request.post("/component/tagAdd", params)),
    // 标签修改
    modify: (params) => TR(request.post("/component/tagModify", params)),
    // 标签删除
    delete: (params) => TR(request.post("/component/tagDelete", params)),
    // 颜色
    color: (params) =>
      TR(request.post("/ttadmin/componentTag/componentTagTypeColors", params)),
    // 标签列表
    findByCondition: (params) =>
      TR(request.post("/ttadmin/componentTag/findByCondition", params)),
    // 新增/编辑组件标签
    saveOrUpdateComponentTags: (params) =>
      TR(
        request.post("/ttadmin/componentTag/saveOrUpdateComponentTags", params)
      ),
    // 组件标签删除
    deleteComponentTag: (params) =>
      TR(request.post("/ttadmin/componentTag/deleteComponentTag", params)),
    // 校验标签是否被组件使用
    componentTagIsInUse: (params) =>
      TR(request.post("/ttadmin/componentTag/componentTagIsInUse", params)),
    // 标签类型列表查询
    listComponentTagTypes: (params) =>
      TR(request.post("/ttadmin/componentTag/listComponentTagTypes", params)),
    // 标签类型列表新增/编辑
    insertOrUpdateTagTypes: (params) =>
      TR(request.post("/ttadmin/componentTag/insertOrUpdateTagTypes", params)),
    // 标签类型删除
    deleteComponentTagType: (params) =>
      TR(request.post("/ttadmin/componentTag/deleteComponentTagType", params)),
    // 校验该标签类型下是否已有标签
    checkComponentTagTypeEmpty: (params) =>
      TR(
        request.post("/ttadmin/componentTag/checkComponentTagTypeEmpty", params)
      ),
    // 获取标签类型颜色列表
    componentTagTypeColors: (params) =>
      TR(request.post("/ttadmin/componentTag/componentTagTypeColors", params)),
    // 校验标签类型名称是否重复
    componentTagTypeIsExists: (params) =>
      TR(
        request.post("/ttadmin/componentTag/componentTagTypeIsExists", params)
      ),
  },
  // 审批人
  approver: {
    // 审批人列表
    page: (params) =>
      TR(request.post("/ttadmin/approver/getApproverManagement", params)),
    // 审批人新增
    add: (params) =>
      TR(request.post("/ttadmin/approver/addApproverManagement", params)),
    // 审批人列表
    users: (params) =>
      TR(request.post("/ttadmin/approver/getTowerUserList", params)),
    // 审批人删除
    delete: (params) =>
      TR(request.post("/ttadmin/approver/delApproverManagement", params)),
  },
  approvalHandle: {
    // 上线审批操作
    approval: (params) =>
      TR(request.post("/ttadmin/componmentVersion/approvalRelease", params)),
    // 下载审批操作
    approvalDownload: (params) =>
      TR(request.post("/ttadmin/componmentVersion/approvalDownload", params)),
    // 审批详情
    applicationDetails: (params) =>
      TR(request.post("/ttadmin/componmentVersion/applicationDetails", params)),
    // 组件版本代码包下载
    downloadCodePackage: (params) =>
      TR(
        request.post("/ttadmin/componentVersion/downloadCodePackage", params, {
          responseType: "blob",
        })
      ),
    // 组件版本JS包下载
    downloadJsPackage: (params) =>
      TR(
        request.post("/ttadmin/componentVersion/downloadJsPackage", params, {
          responseType: "blob",
        })
      ),
    // 资源包下载统计接口
    downloadRecords: (params) =>
      TR(
        request.post("/ttadmin/componentVersion/downloadRecords", params, {
          responseType: "blob",
        })
      ),
  },
};
